﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DA2
{
    public partial class Form1 : Form
    {
        int manager = 0;
        int currentInsert = 1;
        int buttonClickUser = 0, del, edit, show, find, change,alarm,exportbill,revenuereport;
        bool statusEditUser = true, statusDelUser = true, statusfindUser = true,statuschangeUser=true;
        int buttonClickMedical = 0;
        bool statusEditMedical = true,statusDelMedical=true,statusFindMedical=true,statusAlarmMedical=true;
        int buttonClickBill = 0;
        bool statusExport = true;
        int buttonClickReport = 0;
        bool statusRevenue = true;
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            showButtonDefault();
            showTabDefault();
        }
        public void showButtonDefault()
        {
            panel1.Visible = true;
            panel2.Visible = false;
            panel3.Visible = false;
            panel4.Visible = false;
        }
        public void showTabDefault()
        {
            tabControl1.Visible = true;
            tabControl1.TabPages.Remove(tabPage2);
            tabControl1.TabPages.Remove(tabPage3);
            tabControl1.TabPages.Remove(tabPage4);
            tabControl1.TabPages.Remove(tabPage5);
            tabControl2.Visible = false;
            tabControl3.Visible = false;
            tabControl4.Visible = false;
        }
        public void showTabUser()
        {
            showTabDefault();
        }
        public void showTabMedical()
        {
            tabControl2.Visible = true;
            tabControl3.Visible = false;
            tabControl4.Visible = false;
            tabControl1.Visible = true;
            tabControl2.TabPages.Remove(tabPage7);
            tabControl2.TabPages.Remove(tabPage8);
            tabControl2.TabPages.Remove(tabPage9);
            tabControl2.TabPages.Remove(tabPage10);
        }
        public void showTabBill()
        {
            tabControl2.Visible = false;
            tabControl3.Visible = true;
            tabControl4.Visible = false;
            tabControl1.Visible = false;
            tabControl3.TabPages.Remove(tabPage12);
        }
        public void showTabReport()
        {
            tabControl2.Visible = false;
            tabControl3.Visible = false;
            tabControl4.Visible = true;
            tabControl1.Visible = false;
            tabControl4.TabPages.Remove(tabPage14);
            tabControl4.TabPages.Remove(tabPage15);
        }
        public void showTab(int manager)
        {
            switch (manager)
            {
                case 0: showTabUser();
                    break;
                case 1: showTabMedical();
                    break;
                case 2: showTabBill();
                    break;
                default: showTabReport();
                    break;
            }
        }
        public void showButtonUser()
        {
            panel1.Visible = true;
            panel2.Visible = false;
            panel3.Visible = false;
            panel4.Visible = false;
        }
        public void showButtonMedical()
        {
            panel1.Visible = false;
            panel2.Visible = true;
            panel3.Visible = false;
            panel4.Visible = false;
        }
        public void showButtonBill()
        {
            panel1.Visible = false;
            panel2.Visible = false;
            panel3.Visible = true;
            panel4.Visible = false;
        }
        public void showButtonReport()
        {
            panel1.Visible = false;
            panel2.Visible = false;
            panel3.Visible = false;
            panel4.Visible = true;
        }
        public void buttonAddUserClick()
        {
            tabControl1.SelectedIndex = 0;
        }
        public void buttonEditUserClick()
        {
             if (statusEditUser)
            {
                tabControl1.TabPages.Insert(currentInsert, tabPage2);
                statusEditUser = false;
                currentInsert++;
                edit = currentInsert - 1;
            }
            tabControl1.SelectedIndex=edit;
        }
        public void buttonDelUserClick()
        {
            if (statusDelUser)
            {
                tabControl1.TabPages.Insert(currentInsert, tabPage3);
                currentInsert++;
                statusDelUser = false;
                del= currentInsert - 1;
            }           
            tabControl1.SelectedIndex=del;
        }
        public void buttonFindUserClick()
        {
            if (statusfindUser)
            {
                tabControl1.TabPages.Insert(currentInsert, tabPage4);
                currentInsert++;
                statusfindUser = false;
                find= currentInsert - 1;
            }            
            tabControl1.SelectedIndex=find;
        }
        public void buttonChangeUserClick()
        {
            if (statuschangeUser)
            {
                tabControl1.TabPages.Insert(currentInsert, tabPage5);
                currentInsert++;
                statuschangeUser = false;
                change= currentInsert - 1;
            }        
            tabControl1.SelectedIndex=change;
        }
        public void processbuttonUser(int button)
        {
            switch (button)
            {
                case 0: buttonAddUserClick();
                    break;
                case 1: buttonEditUserClick();
                    break;
                case 2: buttonDelUserClick();
                    break;
                case 3: buttonFindUserClick();
                    break;
                default: buttonChangeUserClick();
                    break;
            }
        }
        public void buttonAddMedicalClick()
        {
            tabControl2.SelectedIndex = 0;
        }
        public void buttonEditMedicalClick()
        {
            if (statusEditMedical)
            {
                tabControl2.TabPages.Insert(currentInsert, tabPage7);
                currentInsert++;
                statusEditMedical = false;
                edit = currentInsert - 1;
            }
            tabControl2.SelectedIndex = edit;
        }
        public void buttonDelMedicalClick()
        {
            if (statusDelMedical)
            {
                tabControl2.TabPages.Insert(currentInsert, tabPage8);
                currentInsert++;
                statusDelMedical = false;
                del = currentInsert - 1;
            }
            tabControl2.SelectedIndex = del;
        }
        public void buttonFindMedicalClick()
        {
            if (statusFindMedical)
            {
                tabControl2.TabPages.Insert(currentInsert, tabPage9);
                currentInsert++;
                statusFindMedical = false;
                find = currentInsert - 1;
            }
            tabControl2.SelectedIndex = find;
        }
        public void buttonAlarmMedicalClick()
        {
            if (statusAlarmMedical)
            {
                tabControl2.TabPages.Insert(currentInsert, tabPage10);
                currentInsert++;
                statusAlarmMedical = false;
                alarm = currentInsert - 1;
            }
            tabControl2.SelectedIndex = alarm;
        }
        public void processButtonMedical(int button)
        {
            switch (button)
            {
                case 0: buttonAddMedicalClick();
                    break;
                case 1: buttonEditMedicalClick();
                    break;
                case 2: buttonDelMedicalClick();
                    break;
                case 3: buttonFindMedicalClick();
                    break;
                default: buttonAlarmMedicalClick();
                    break;
            }
        }
        public void buttonImportBillClick()
        {
            tabControl3.SelectedIndex = 0;
        }
        public void buttonExportBillClick()
        {
            if (statusExport)
            {
                tabControl3.TabPages.Insert(currentInsert, tabPage12);
                currentInsert++;
                statusExport = false;
                exportbill = currentInsert - 1;
            }
            tabControl3.SelectedIndex = exportbill;
        }
        public void processButtonBill(int button)
        {
            switch (button)
            {
                case 0: buttonImportBillClick();
                    break;
                default: buttonExportBillClick();
                    break;
            }
        }
        public void buttonMedicalReportClick()
        {
            tabControl4.SelectedIndex = 0;
        }
        public void buttonRevenueReportClick()
        {
            if (statusRevenue)
            {
                tabControl4.TabPages.Insert(currentInsert, tabPage14);
                tabControl4.TabPages.Insert(currentInsert + 1, tabPage15);
                currentInsert++;
                statusRevenue = false;
                revenuereport = currentInsert - 1;
            }
            tabControl4.SelectedIndex = revenuereport;
        }
        public void processButtonReport(int button)
        {
            switch (button)
            {
                case 0: buttonMedicalReportClick();
                    break;
                default: buttonRevenueReportClick();
                    break;
            }
        }



        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            manager = 3;
            statusRevenue = true;
            currentInsert = 1;
            showTab(manager);
            showButtonReport();
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            manager = 0;
            statuschangeUser = true;
            statusDelUser = true;
            statusEditUser = true;
            statusfindUser = true;
            currentInsert = 1;
            showTab(manager);
            showButtonUser();
        }




        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            manager = 1;
            statusAlarmMedical = true;
            statusEditMedical = true;
            statusDelMedical = true;
            statusFindMedical = true;
            currentInsert = 1;
            showTab(manager);
            showButtonMedical();
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            manager = 2;
            statusExport = true;
            currentInsert = 1;
            showTab(manager);
            showButtonBill();
        }

        private void toolStripButton9_Click(object sender, EventArgs e)
        {
            buttonClickUser = 0;
            processbuttonUser(buttonClickUser);
        }

        private void toolStripButton10_Click(object sender, EventArgs e)
        {
            buttonClickUser = 1;
            processbuttonUser(buttonClickUser);
        }

        private void toolStripButton11_Click(object sender, EventArgs e)
        {
            buttonClickUser = 2;
            processbuttonUser(buttonClickUser);
        }

        private void toolStripButton12_Click_1(object sender, EventArgs e)
        {
            buttonClickUser = 3;
            processbuttonUser(buttonClickUser);
        }

        private void toolStripButton13_Click(object sender, EventArgs e)
        {
            buttonClickUser = 4;
            processbuttonUser(buttonClickUser);
        }

        private void toolStripButton14_Click(object sender, EventArgs e)
        {
            buttonClickMedical = 0;
            processButtonMedical(buttonClickMedical);
        }

        private void toolStripButton15_Click(object sender, EventArgs e)
        {
            buttonClickMedical = 1;
            processButtonMedical(buttonClickMedical);
        }

        private void toolStripButton16_Click(object sender, EventArgs e)
        {
            buttonClickMedical = 2;
            processButtonMedical(buttonClickMedical);
        }

        private void toolStripButton17_Click(object sender, EventArgs e)
        {
            buttonClickMedical = 3;
            processButtonMedical(buttonClickMedical);
        }

        private void toolStripButton19_Click(object sender, EventArgs e)
        {
            buttonClickMedical = 4;
            processButtonMedical(buttonClickMedical);
        }

        private void toolStripButton20_Click(object sender, EventArgs e)
        {
            buttonClickBill = 0;
            processButtonBill(buttonClickBill);
        }

        private void toolStripButton21_Click(object sender, EventArgs e)
        {
            buttonClickBill = 1;
            processButtonBill(buttonClickBill);
        }

        private void toolStripButton22_Click(object sender, EventArgs e)
        {
            buttonClickReport = 0;
            processButtonReport(buttonClickReport);
        }

        private void toolStripButton23_Click(object sender, EventArgs e)
        {
            buttonClickReport = 1;
            processButtonReport(buttonClickReport);
        }

        private void tabPage13_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text = "nguyen";
        }

        private void btn_XoaThuocHDN_Click(object sender, EventArgs e)
        {

        }

        private void tabPage13_Click_1(object sender, EventArgs e)
        {

        }

        private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void tabPage14_Click(object sender, EventArgs e)
        {








        }
        
        
        
        
        
        
        
        
        
        
        
        
        }
    }
